package com.cb.domain.dao.order.impl;

import java.sql.SQLException;
import java.util.List;
import java.util.ArrayList;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.stereotype.Repository;
import com.cb.core.dao.hibernate.GenericDAOHibernate;
import com.cb.domain.model.order.Policy;
import com.cb.domain.dao.order.PolicyDAO;
import com.cb.core.webapp.paging.PagingBean;

@Repository
public class PolicyDAOImpl extends GenericDAOHibernate<Policy, Long> implements PolicyDAO {
	public PolicyDAOImpl() {
		super(Policy.class);
	}
	
	/**
	 * {@inheritDoc}
	 */
	public List<Policy> getByVo(Policy vo, PagingBean pb) {
		List<Object>paramList=new ArrayList<Object>();
		String hql="from Policy vo where 1=1";
		
		/**TODO 添加自己的需要加入的查询条件
		if(StringUtils.isNotEmpty(vo.getUsername())){
			hql+=" and vo.username like ?";
			paramList.add("%"+vo.getUsername()+"%");
		}**/
		
		List <Policy>list=this.find(hql, paramList.toArray(), pb);
		return list;
	}

	@Override
	public void deleteAll() {
		// TODO Auto-generated method stub
		Query query=this.getSession().createQuery("delete Policy");
	    query.executeUpdate();
	}
}

